package com.zbkj.crmeb.store.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.crmeb.enums.MainCategoriesEnum;
import com.zbkj.crmeb.enums.SkuNumberEnum;
import com.zbkj.crmeb.merchant.api.request.CantonFairInfoRequest;
import com.zbkj.crmeb.store.dao.CantonFairInfoDao;
import com.zbkj.crmeb.store.model.CantonFairInfo;
import com.zbkj.crmeb.store.service.CantonFairInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class CantonFairInfoServiceImpl extends ServiceImpl<CantonFairInfoDao, CantonFairInfo> implements CantonFairInfoService {

    @Override
    public Boolean savInfo(CantonFairInfoRequest request) {
        CantonFairInfo cantonFairInfo = new CantonFairInfo();
        BeanUtils.copyProperties(request, cantonFairInfo);
        cantonFairInfo.setMainCategories(Objects.requireNonNull(MainCategoriesEnum.getEnum(request.getMainCategories())).getCode());
        cantonFairInfo.setSkuNumber(Objects.requireNonNull(SkuNumberEnum.getEnum(request.getSkuNumber())).getCode());
        return this.save(cantonFairInfo);
    }
}
